#include "testApp.h"

//--------------------------------------------------------------
void testApp::setup(){
    x = 0;
    y = ofGetHeight()/2.0;
    
    rot = PI;
    
    sinCircX = 0;
    sinCircY = 0;
    
    randCircX = 0;
    randCircY = 0;
    
    whiteCircX = 0;
    whiteCircY = 0;
    
    ofSetBackgroundAuto(false);
}

//--------------------------------------------------------------
void testApp::update(){

    randCircX += 0.1;
    
    if(randCircX > ofGetWidth()){
        randCircX = 0;
    }
    
    randCircY = ofRandom(ofGetHeight() * .75, ofGetHeight());
    
    whiteCircX += 0.5;
    
    if(whiteCircX > ofGetWidth()){
        whiteCircX = 0;
    }
    
    whiteCircY = ofNoise(whiteCircX/100.0) * 300;
}

//--------------------------------------------------------------
void testApp::draw(){
    
    ofSetColor(255);
    ofCircle(whiteCircX, whiteCircY, 10);
    
    ofSetColor(0, 0, 255);
    ofCircle(randCircX, randCircY, 10);
    
    sinCircX += 0.5;
    
    sinCircY = ofGetHeight()/2.0 + sin(sinCircX/50.0) * 200;
    
    ofLog(OF_LOG_ERROR, "sinCircY: " + ofToString(sinCircY));
    
    ofSetColor(255, 0, 0);
    ofCircle(sinCircX, sinCircY, 10);
    
    if(sinCircX > ofGetWidth()){
        sinCircX = 0;
    }
    
//    x += 0.1;
    
    x = ofGetWidth()/2.0 + sin(rot) * 100;
    y = ofGetHeight()/2.0 + cos(rot) * 100;
    
    
    ofSetColor(0, 255, 0);
    ofCircle(x, y, 10);

    
    
    if(ofGetKeyPressed(358)){
        rot -= 0.01;
    } else if(ofGetKeyPressed(356)){
        rot += 0.01;
    }
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){
//    ofLog(OF_LOG_ERROR, "key: " + ofToString(key));
//    
//    if(key == 358){
//        x += 10;
//    } else if(key == 356){
//        x -= 10;
//    }
}

//--------------------------------------------------------------
void testApp::keyReleased(int key){

}

//--------------------------------------------------------------
void testApp::mouseMoved(int _x, int _y ){
//    x = _x;
//    y = _y;
}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){ 

}